package com.wwwarehouse.taskcenter.fragment.job_point.step5;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;

import com.wwwarehouse.common.activity.base.BaseFragment;
import com.wwwarehouse.common.custom_widget.state_layout.StateLayout;
import com.wwwarehouse.taskcenter.R;
import com.wwwarehouse.taskcenter.adapter.job_point.JobPointChooseObject4Adapter;
import com.wwwarehouse.taskcenter.bean.job_point.TaskPointChooseRelativethingBean;

import java.util.ArrayList;

/**
 * @创建者 chenchao.
 * @创建时间 2017/10/25 18:57
 * @描述 ${TODO}
 */

public class UnitGroupDetailFragment5 extends BaseFragment {

    private View mView;
    private RecyclerView mTaskPointRecycleview;
    private StateLayout mSlLayout;
    private static final int pageSize = 10;
    private ArrayList<TaskPointChooseRelativethingBean.ListBean> currentList;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        mView = inflater.inflate(R.layout.fragment_choose_object_detail_6, container, false);
        initView(mView);
        return mView;
    }

    @Override
    public void setTitle() {
        if (peekFragment() instanceof UnitGroupDetailFragment5) {
            mActivity.setTitle(getString(R.string.taskpoint_choose_relatething));
        }
    }

    @Override
    public void requestDatas() {

    }

    private void initView(View mView) {
        mTaskPointRecycleview = (RecyclerView) mView.findViewById(R.id.task_point_recycleview);
        mSlLayout = (StateLayout) mView.findViewById(R.id.sl_layout);

        mTaskPointRecycleview.setLayoutManager(new LinearLayoutManager(mActivity));

        int page = getArguments().getInt("page");
        ArrayList<TaskPointChooseRelativethingBean.ListBean> list = getArguments().getParcelableArrayList("dataList");

        currentList = new ArrayList<>();
        for(int i = (page - 1) * pageSize ; i < (list.size()>page*pageSize?page*pageSize:list.size()) ; i ++ ){
            currentList.add(list.get(i));
        }
        mTaskPointRecycleview.setAdapter(new JobPointChooseObject4Adapter(currentList,mActivity));

    }

    @Override
    public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
        return null;
    }
}
